package com.ying.timed.controller;

import com.ying.common.entity.Response;
import com.ying.timed.entity.Timed;
import com.ying.timed.service.TimedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/timed")
public class TimedController {

    @Autowired
    private TimedService timedService;

    /**
     * 添加定时任务
     * @param timed
     * @return
     */
    @PostMapping(value = "/insertTimed")
    public Response insertTimed(@RequestBody Timed timed) {
        Response resposne = timedService.insertTimed(timed);
        return resposne;
    }

    /**
     * 编辑定时任务
     * @param timed
     * @return
     */
    @PostMapping(value = "/updateTimed")
    public Response updateTimed(@RequestBody Timed timed) {
        Response response = timedService.updateTimed(timed);
        return response;
    }

    /**
     * 删除定时任务
     * @param timed
     * @return
     */
    @PostMapping(value = "/deleteTimed")
    public Response deleteTimed(@RequestBody Timed timed) {
        Response response = timedService.deleteTimed(timed);
        return response;
    }

    /**
     * 修改定时任务状态
     * @param timed
     * @return
     */
    @PostMapping(value = "/updateStatus")
    public Response updateStatus(@RequestBody Timed timed) {
        Response response = timedService.updateStatus(timed);
        return response;
    }

    /**
     * 查询定时任务
     * @return
     */
    @GetMapping(value = "/selectTimed")
    public Response selectTimed() {
        Response response = timedService.selectTimed();
        return response;
    }

    /**
     * 手动执行定时任务
     * @return
     */
    @PostMapping(value = "/executeTask")
    public Response executeTask(@RequestBody Timed timed) {
        Response response = timedService.executeTask(timed);
        return response;
    }

}
